package com.pzhu.dormitory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pzhu.dormitory.dao.StudentDao;
import com.pzhu.dormitory.entity.StudentEntity;
import com.pzhu.dormitory.service.StudentService;
import com.pzhu.dormitory.utils.PageUtils;
import com.pzhu.dormitory.utils.Query;
import com.pzhu.dormitory.vo.StudentVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("studentService")
@AllArgsConstructor
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {

    private final  StudentDao studentDao;

    @Override
    public PageUtils<StudentEntity> queryPage(Map<String, Object> params) {
        IPage<StudentEntity> page = this.page(
                new Query<StudentEntity>().getPage(params),
                new QueryWrapper<>()
        );
        return new PageUtils<>(page);
    }

    @Override
    public PageUtils<StudentVo> queryPageStudentVo(Map<String, Object> params) {
        Page<StudentVo> page = new Query<StudentVo>().getPage(params);
        // 查询基本数据
        Page<StudentVo> DoctorVoPage = studentDao.queryPageVo(page, params);
        return new PageUtils<>(DoctorVoPage);
    }

}
